<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/common/comonFoodSelect.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<script type="text/javascript" src="${ctx}/js/checkFrom.js"></script>
<title>新增采购详细计划</title>
	<script type="text/javascript">
		function  custom(obj){

			var url1="${ctx}/buyPlanDetail/check?foodName="+obj.foodName;
			$.get(url1,function(data,status){
				if(status=="success"){
				if(data=="true"){

					alert("该食品以及存在，不能重复添加");
				}else{
					$("#foodId").val(obj.foodId);
					$("#foodName").val(obj.foodName);
					getPrice();
				}

				}else{
					alert("服务器异常");
				}
			});

          function getPrice(){
			  var url="${ctx}/price/getPrice?id="+obj.foodId;
			  $.get(url,function(data,status){
				  if(status=="success"){
					  var price=eval('('+data+')');
					  $("#foodPrice").val(price.salePrice);
				  }else{
					  alert("服务器异常");
				  }
			  });
		  }

		}
	</script>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#buyNum").change(function(){
				var buyNum=$("#buyNum").val();
				var foodPrice=$("#foodPrice").val();
				$("#buyTotalMoney").val(Number(buyNum)*Number(foodPrice));
			});
		});
	</script>
</head>
<body>
<%--<input type="hidden" id="date-input" />--%>
<a href='${ctx }/buyPlan/list' >返回采购计划列表</a>
<hr />
<form action="${ctx }/buyPlanDetail/save" method="post">
	<input type="hidden" name="buyPlanId" value="${buyPlanId}">
	<input type="hidden" name="foodId" id="foodId">
<table style="width: 300px;margin: auto;">
<tr>
	<td>食品名称</td>
	<td><input type="text" name="foodName" id="foodName" readonly/></td>
</tr>
	<tr>
		<td>食品价格</td>
		<td><input type="text" name="foodPrice" id="foodPrice" value="0" required/></td>
	</tr>
	<tr>
		<td>计划采购数量</td>
		<td><input type="text" name="buyNum" id="buyNum" value="0" required/></td>
	</tr>
	<tr>
		<td>计划采购金额</td>
		<td><input type="text" name="buyTotalMoney" id="buyTotalMoney" value="0" readonly></td>
	</tr>

	<tr>
		<td>备注</td>
		<td><input type="text" name="remarks" id="remarks" /></td>
	</tr>


	<td></td>
	<td><input type="submit" value="保存"> </td>
</tr>
</table>
</form>
</body>
</html>